<form method="<?echo $this->form->getMethod() ?>" action="<?echo $this->form->getAction()?>" id="<?echo $this->form->getId()?>">
<div style="padding:7px 0;">
	<?php
		echo $this->form->submit->renderViewHelper();
		echo $this->form->eliminar->renderViewHelper();
	?>
</div>
<?php 
	$errors = $this->form->muestraErrores($this->form->getMessages());
	if(count($errors) !=0) echo $this->formErrors($errors);	
?>
<div id='jqxTabsClientes'>
	<ul style='margin-left: 20px;'>
    	<li>
        	Datos Princiaples
        </li>
        <li>Datos Contacto
	</ul>
	<div>
		<?php
		echo $this->form->id_clientes->renderViewHelper();
			
		echo $this->form->nombre->renderLabel(); 
		echo $this->form->nombre->renderViewHelper();
		
		echo $this->form->apellidos->renderLabel(); 
		echo $this->form->apellidos->renderViewHelper();
				
		echo $this->form->nif->renderLabel(); 
		echo $this->form->nif->renderViewHelper();
		
		echo $this->form->direccion->renderLabel(); 
		echo $this->form->direccion->renderViewHelper();
		?>
		<div>
			<div style="float:left;padding-right:5px">
				<?php 
				echo $this->form->dire_num->renderLabel(); 
				echo $this->form->dire_num->renderViewHelper();
				?>
			</div>
			<div style="float:left;padding-right:5px">
				<?php 
				echo $this->form->dire_piso->renderLabel(); 
				echo $this->form->dire_piso->renderViewHelper();
				?>
			</div>
			<div style="float:left;padding-right:5px">
				<?php 
				echo $this->form->dire_puerta->renderLabel(); 
				echo $this->form->dire_puerta->renderViewHelper();
				?>
			</div>						
		</div>
		<div style="clear:both;"></div>
		<div>
			<div style="float:left;padding-right:5px">
				<?php 
				echo $this->form->dire_cp->renderLabel(); 
				echo $this->form->dire_cp->renderViewHelper();
				?>
			</div>
			<div style="float:left;padding-right:5px">
				<?php 
				echo $this->form->poblacion->renderLabel(); 
				echo $this->form->poblacion->renderViewHelper();
				?>
			</div>
		</div>
		<div style="clear:both;"></div>
		<?php
		echo $this->form->provincia->renderLabel(); 
		echo $this->form->provincia->renderViewHelper();
		
		echo $this->form->pais->renderLabel(); 
		echo $this->form->pais->renderViewHelper();
		
		echo $this->form->descuento->renderLabel(); 
		echo $this->form->descuento->renderViewHelper();
		?>
        </div>
        <div>
        <?php 
			echo $this->form->telefono->renderLabel(); 
			echo $this->form->telefono->renderViewHelper();
			
			echo $this->form->telefono2->renderLabel(); 
			echo $this->form->telefono2->renderViewHelper();
			
			echo $this->form->fax->renderLabel(); 
			echo $this->form->fax->renderViewHelper();
			
			echo $this->form->cod_tipo_clie->renderLabel(); 
			echo $this->form->cod_tipo_clie->renderViewHelper();
			
			echo $this->form->empresa->renderLabel(); 
			echo $this->form->empresa->renderViewHelper();
			
			echo $this->form->mail->renderLabel(); 
			echo $this->form->mail->renderViewHelper();
			
			echo $this->form->url->renderLabel(); 
			echo $this->form->url->renderViewHelper();
			
			echo $this->form->activo->renderLabel(); 
			echo $this->form->activo->renderViewHelper();
        ?>
	</div>        
</div>
<?php
	echo $this->form->error_form->renderViewHelper();
?>
</form>
<script type="text/javascript">
	//Tabs
	var theme = '';
	$('#jqxTabsClientes').jqxTabs({ width: "100%", position: 'top', theme: theme });
	$('#jqxTabsClientes').jqxTabs({ height: 440 });

	//Botones
	$("#submit").jqxButton({ width: '150', height: '25'});
	$("#eliminar").jqxButton({ width: '100', height: '25'});

	//CSS
	$('dt').addClass('dt-forms');
	$('#jqxTabsClientes > div').addClass('tabStyles');

	//Submit
    $('#frmClientes').submit(function(event) {
	   	event.preventDefault();  
	  	var url = $(this).attr('action');  
		var datos = $(this).serialize();  
		jQuery.ajax({
            type: 'POST',
            url: url,
            dataType:'html',
            data:datos,
            success:function(resultado){
            	$('#jqxWindowContent').html(resultado);
				var error = parseInt($('input[name=\"error_form\"]').val());
				if(error == 0)
				{							
					//No error
					if($('#jqxGridmnuClientesActivos').length >0)
						sourceActivos = gridSource('mnuClientesActivos', 'refresh');
					if($('#jqxGridmnuClientesAnulados').length >0)
						sourceAnulados = gridSource('mnuClientesAnulados', 'refresh');

					//Cerramos la ventana
					$('#jqxWindow').jqxWindow('hide');
				}
				else
				{
					//Error
				}
				//window.console.log(error);
				
            },
            error:function (xhr, ajaxOptions, thrownError){
                alert('Error en el formulario.');
            }    
        });
	});

	//Eliminar
	$('#eliminar').click(function(){
		if(confirm('¿Desea eliminar el registro?'))
		{
			var id = $('#id_clientes').val();
			var url = '/clientes/delete/value/'+id;  
			var datos = $(this).serialize();
									
			jQuery.ajax({
                type: 'post',
                url: url,
                dataType:'html',
                data:datos,
                success:function(resultado){
					//Grid
		            //No error
					if($('#jqxGridmnuClientesActivos').length >0)
						sourceActivos = gridSource('mnuClientesActivos', 'refresh');
					if($('#jqxGridmnuClientesAnulados').length >0)
						sourceAnulados = gridSource('mnuClientesAnulados', 'refresh');
					
					//Cerramos la ventana
					$('#jqxWindow').jqxWindow('hide');
					
                },
                error:function (xhr, ajaxOptions, thrownError){
                    alert('Error al eliminar.');
                }    
            });
		}
	});
</script>


